3.9.14 \(\int \frac {a+b x+c x^2}{(d+e x) (f+g x)} \, dx\) [814]

Optimal. Leaf size=83 \[ \frac {c x}{e g}+\frac {\left (c d^2-b d e+a e^2\right ) \log (d+e x)}{e^2 (e f-d g)}-\frac {\left (c f^2-b f g+a g^2\right ) \log (f+g x)}{g^2 (e f-d g)} \]

[Out]

c*x/e/g+(a*e^2-b*d*e+c*d^2)*ln(e*x+d)/e^2/(-d*g+e*f)-(a*g^2-b*f*g+c*f^2)*ln(g*x+f)/g^2/(-d*g+e*f)

________________________________________________________________________________________

Rubi [A]
time = 0.06, antiderivative size = 83, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 1, integrand size = 25, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.040, Rules used = {907} \begin {gather*} \frac {\log (d+e x) \left (a e^2-b d e+c d^2\right )}{e^2 (e f-d g)}-\frac {\log (f+g x) \left (a g^2-b f g+c f^2\right )}{g^2 (e f-d g)}+\frac {c x}{e g} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a + b*x + c*x^2)/((d + e*x)*(f + g*x)),x]

[Out]

(c*x)/(e*g) + ((c*d^2 - b*d*e + a*e^2)*Log[d + e*x])/(e^2*(e*f - d*g)) - ((c*f^2 - b*f*g + a*g^2)*Log[f + g*x]
)/(g^2*(e*f - d*g))

Rule 907

Int[((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_))^(n_)*((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :
> Int[ExpandIntegrand[(d + e*x)^m*(f + g*x)^n*(a + b*x + c*x^2)^p, x], x] /; FreeQ[{a, b, c, d, e, f, g}, x] &
& NeQ[e*f - d*g, 0] && NeQ[b^2 - 4*a*c, 0] && NeQ[c*d^2 - b*d*e + a*e^2, 0] && IntegerQ[p] && ((EqQ[p, 1] && I
ntegersQ[m, n]) || (ILtQ[m, 0] && ILtQ[n, 0]))

Rubi steps

\begin {align*} \int \frac {a+b x+c x^2}{(d+e x) (f+g x)} \, dx &=\int \left (\frac {c}{e g}+\frac {c d^2-b d e+a e^2}{e (e f-d g) (d+e x)}+\frac {c f^2-b f g+a g^2}{g (-e f+d g) (f+g x)}\right ) \, dx\\ &=\frac {c x}{e g}+\frac {\left (c d^2-b d e+a e^2\right ) \log (d+e x)}{e^2 (e f-d g)}-\frac {\left (c f^2-b f g+a g^2\right ) \log (f+g x)}{g^2 (e f-d g)}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.04, size = 85, normalized size = 1.02 \begin {gather*} \frac {c x}{e g}-\frac {\left (-c d^2+b d e-a e^2\right ) \log (d+e x)}{e^2 (e f-d g)}-\frac {\left (c f^2-b f g+a g^2\right ) \log (f+g x)}{g^2 (e f-d g)} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a + b*x + c*x^2)/((d + e*x)*(f + g*x)),x]

[Out]

(c*x)/(e*g) - ((-(c*d^2) + b*d*e - a*e^2)*Log[d + e*x])/(e^2*(e*f - d*g)) - ((c*f^2 - b*f*g + a*g^2)*Log[f + g
*x])/(g^2*(e*f - d*g))

________________________________________________________________________________________

Maple [A]
time = 0.10, size = 84, normalized size = 1.01

method result size
default \(\frac {c x}{e g}+\frac {\left (-a \,e^{2}+b d e -c \,d^{2}\right ) \ln \left (e x +d \right )}{\left (d g -e f \right ) e^{2}}+\frac {\left (a \,g^{2}-b f g +c \,f^{2}\right ) \ln \left (g x +f \right )}{g^{2} \left (d g -e f \right )}\) \(84\)
norman \(\frac {c x}{e g}+\frac {\left (a \,g^{2}-b f g +c \,f^{2}\right ) \ln \left (g x +f \right )}{g^{2} \left (d g -e f \right )}-\frac {\left (a \,e^{2}-b d e +c \,d^{2}\right ) \ln \left (e x +d \right )}{\left (d g -e f \right ) e^{2}}\) \(84\)
risch \(\frac {c x}{e g}+\frac {\ln \left (-g x -f \right ) a}{d g -e f}-\frac {\ln \left (-g x -f \right ) b f}{g \left (d g -e f \right )}+\frac {\ln \left (-g x -f \right ) c \,f^{2}}{g^{2} \left (d g -e f \right )}-\frac {\ln \left (e x +d \right ) a}{d g -e f}+\frac {\ln \left (e x +d \right ) b d}{\left (d g -e f \right ) e}-\frac {\ln \left (e x +d \right ) c \,d^{2}}{\left (d g -e f \right ) e^{2}}\) \(151\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((c*x^2+b*x+a)/(e*x+d)/(g*x+f),x,method=_RETURNVERBOSE)

[Out]

c*x/e/g+(-a*e^2+b*d*e-c*d^2)/(d*g-e*f)/e^2*ln(e*x+d)+1/g^2*(a*g^2-b*f*g+c*f^2)/(d*g-e*f)*ln(g*x+f)

________________________________________________________________________________________

Maxima [A]
time = 0.29, size = 86, normalized size = 1.04 \begin {gather*} \frac {c x e^{\left (-1\right )}}{g} + \frac {{\left (c f^{2} - b f g + a g^{2}\right )} \log \left (g x + f\right )}{d g^{3} - f g^{2} e} - \frac {{\left (c d^{2} - b d e + a e^{2}\right )} \log \left (x e + d\right )}{d g e^{2} - f e^{3}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c*x^2+b*x+a)/(e*x+d)/(g*x+f),x, algorithm="maxima")

[Out]

c*x*e^(-1)/g + (c*f^2 - b*f*g + a*g^2)*log(g*x + f)/(d*g^3 - f*g^2*e) - (c*d^2 - b*d*e + a*e^2)*log(x*e + d)/(
d*g*e^2 - f*e^3)

________________________________________________________________________________________

Fricas [A]
time = 1.22, size = 96, normalized size = 1.16 \begin {gather*} \frac {c d g^{2} x e - c f g x e^{2} + {\left (c f^{2} - b f g + a g^{2}\right )} e^{2} \log \left (g x + f\right ) - {\left (c d^{2} g^{2} - b d g^{2} e + a g^{2} e^{2}\right )} \log \left (x e + d\right )}{d g^{3} e^{2} - f g^{2} e^{3}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c*x^2+b*x+a)/(e*x+d)/(g*x+f),x, algorithm="fricas")

[Out]

(c*d*g^2*x*e - c*f*g*x*e^2 + (c*f^2 - b*f*g + a*g^2)*e^2*log(g*x + f) - (c*d^2*g^2 - b*d*g^2*e + a*g^2*e^2)*lo
g(x*e + d))/(d*g^3*e^2 - f*g^2*e^3)

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 420 vs. \(2 (70) = 140\).
time = 74.15, size = 420, normalized size = 5.06 \begin {gather*} \frac {c x}{e g} + \frac {\left (a g^{2} - b f g + c f^{2}\right ) \log {\left (x + \frac {a d e g^{2} + a e^{2} f g - 2 b d e f g + c d^{2} f g + c d e f^{2} - \frac {d^{2} e g \left (a g^{2} - b f g + c f^{2}\right )}{d g - e f} + \frac {2 d e^{2} f \left (a g^{2} - b f g + c f^{2}\right )}{d g - e f} - \frac {e^{3} f^{2} \left (a g^{2} - b f g + c f^{2}\right )}{g \left (d g - e f\right )}}{2 a e^{2} g^{2} - b d e g^{2} - b e^{2} f g + c d^{2} g^{2} + c e^{2} f^{2}} \right )}}{g^{2} \left (d g - e f\right )} - \frac {\left (a e^{2} - b d e + c d^{2}\right ) \log {\left (x + \frac {a d e g^{2} + a e^{2} f g - 2 b d e f g + c d^{2} f g + c d e f^{2} + \frac {d^{2} g^{3} \left (a e^{2} - b d e + c d^{2}\right )}{e \left (d g - e f\right )} - \frac {2 d f g^{2} \left (a e^{2} - b d e + c d^{2}\right )}{d g - e f} + \frac {e f^{2} g \left (a e^{2} - b d e + c d^{2}\right )}{d g - e f}}{2 a e^{2} g^{2} - b d e g^{2} - b e^{2} f g + c d^{2} g^{2} + c e^{2} f^{2}} \right )}}{e^{2} \left (d g - e f\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c*x**2+b*x+a)/(e*x+d)/(g*x+f),x)

[Out]

c*x/(e*g) + (a*g**2 - b*f*g + c*f**2)*log(x + (a*d*e*g**2 + a*e**2*f*g - 2*b*d*e*f*g + c*d**2*f*g + c*d*e*f**2
 - d**2*e*g*(a*g**2 - b*f*g + c*f**2)/(d*g - e*f) + 2*d*e**2*f*(a*g**2 - b*f*g + c*f**2)/(d*g - e*f) - e**3*f*
*2*(a*g**2 - b*f*g + c*f**2)/(g*(d*g - e*f)))/(2*a*e**2*g**2 - b*d*e*g**2 - b*e**2*f*g + c*d**2*g**2 + c*e**2*
f**2))/(g**2*(d*g - e*f)) - (a*e**2 - b*d*e + c*d**2)*log(x + (a*d*e*g**2 + a*e**2*f*g - 2*b*d*e*f*g + c*d**2*
f*g + c*d*e*f**2 + d**2*g**3*(a*e**2 - b*d*e + c*d**2)/(e*(d*g - e*f)) - 2*d*f*g**2*(a*e**2 - b*d*e + c*d**2)/
(d*g - e*f) + e*f**2*g*(a*e**2 - b*d*e + c*d**2)/(d*g - e*f))/(2*a*e**2*g**2 - b*d*e*g**2 - b*e**2*f*g + c*d**
2*g**2 + c*e**2*f**2))/(e**2*(d*g - e*f))

________________________________________________________________________________________

Giac [A]
time = 4.68, size = 88, normalized size = 1.06 \begin {gather*} \frac {c x e^{\left (-1\right )}}{g} + \frac {{\left (c f^{2} - b f g + a g^{2}\right )} \log \left ({\left | g x + f \right |}\right )}{d g^{3} - f g^{2} e} - \frac {{\left (c d^{2} - b d e + a e^{2}\right )} \log \left ({\left | x e + d \right |}\right )}{d g e^{2} - f e^{3}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c*x^2+b*x+a)/(e*x+d)/(g*x+f),x, algorithm="giac")

[Out]

c*x*e^(-1)/g + (c*f^2 - b*f*g + a*g^2)*log(abs(g*x + f))/(d*g^3 - f*g^2*e) - (c*d^2 - b*d*e + a*e^2)*log(abs(x
*e + d))/(d*g*e^2 - f*e^3)

________________________________________________________________________________________

Mupad [B]
time = 3.42, size = 84, normalized size = 1.01 \begin {gather*} \frac {\ln \left (d+e\,x\right )\,\left (c\,d^2-b\,d\,e+a\,e^2\right )}{e^3\,f-d\,e^2\,g}+\frac {\ln \left (f+g\,x\right )\,\left (c\,f^2-b\,f\,g+a\,g^2\right )}{g^2\,\left (d\,g-e\,f\right )}+\frac {c\,x}{e\,g} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a + b*x + c*x^2)/((f + g*x)*(d + e*x)),x)

[Out]

(log(d + e*x)*(a*e^2 + c*d^2 - b*d*e))/(e^3*f - d*e^2*g) + (log(f + g*x)*(a*g^2 + c*f^2 - b*f*g))/(g^2*(d*g -
e*f)) + (c*x)/(e*g)

________________________________________________________________________________________